import React from "react";
import {Button, Checkbox, Icon, Tooltip /** , Input, Radio */} from "antd";
import {openNotificationWithIcon} from "utils/comm";
import NoticeUserAddTable from "components/NoticeUserAddTable/NoticeUserAddTable";
import dsStyles from "./DuedateSetting.less";
import styles from "./Pannel.less";

class CarbonCopySetting extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      userSelectorVisible: false,
    };
    this.openNotificationWithIcon = openNotificationWithIcon.bind(this);
  }

  onEdit = () => {
    this.setState({
      userSelectorVisible: true,
    });
  };

  onChange = (value) => {
    const {onChange} = this.props;
    onChange(value);
  }

  render() {
    const {
      userSelectorVisible,
    } = this.state;
    const {value: users, disable} = this.props;

    return (
      <>
        <div className={styles.content_item} style={{display: "block"}}>
          <span className={styles.item_label} style={{paddingBottom: 0}}>
            <Checkbox
              checked={!!users}
              disabled={disable}
              onChange={() => this.onChange(users ? null : [])}
            >
              抄送人设置
            </Checkbox>
            <Tooltip placement="topLeft" title="用于发送MQ消息">
              <Icon
                style={{cursor: "pointer"}}
                theme="filled"
                type="question-circle"
              />
            </Tooltip>
          </span>

          {!!users && (
            <div className={dsStyles.box}>
              {/*
              <div className={styles.delay_box}>
                { null }
              </div>
              */}
              <Button
                className={dsStyles.btn}
                type="primary"
                onClick={() => this.onEdit()}
              >
                编辑
              </Button>
            </div>
          )}
        </div>
        {
          userSelectorVisible && (
            <NoticeUserAddTable
              handleCancel={() => this.setState({userSelectorVisible: false})}
              onOk={this.onChange}
              visible={userSelectorVisible}
              onfirmLoading={false}
              users={users}
              okText="确定"
            />
          )}
      </>
    );
  }
}

export default CarbonCopySetting;
